package com.example.demo.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.example.demo.custom.AjaxResult;
import com.example.demo.custom.BaseController;
import com.example.demo.entity.TargetAndBackMonkey;
import com.example.demo.form.TargetAndBackMonkeyForm;
import com.example.demo.service.TargetAndBackMonkeyService;
@RestController
@RequestMapping(value = "/TargetAndBackMonkey")
public class TargetAndBackMonkeyController extends BaseController<TargetAndBackMonkey, Integer,TargetAndBackMonkeyForm>{
	@Autowired
	private TargetAndBackMonkeyService service;
	
	@RequestMapping(value = "/findbydate")
	public Object findbydate(TargetAndBackMonkeyForm form) {
		TargetAndBackMonkey model=null;
		if(form.getYears()!=null) {
			Integer years=form.getYears();
			Integer month=form.getMonth();
		model = service.findByMonthAndYears(month, years);
		}
		return new AjaxResult(model);
	}
	@RequestMapping(value = "/findyears")
	public Boolean findyears(TargetAndBackMonkeyForm form) {
		Boolean flag = false;
		for (TargetAndBackMonkey aaa: service.findAll()) {
			int bbb = aaa.getYears();
			int ccc = aaa.getMonth();
			int ddd = form.getYears();
			int eee = form.getMonth();
			if(ddd==bbb&&eee==ccc) {
				flag = true;
			}
		}
		return flag;
		
	}
	
}
